package com.SouthernWall_404.AgeSuitcase.Common.API.GuiAPI.Animation;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;

public class Breathing extends AbstractAnimation{

    private float min =0.3f;
    private float mergin;
    public Breathing(AbstractWidget abstractWidget, int time) {
        super(abstractWidget, time);

        mergin=(float)((1- min)/0.5);
    }

    public Breathing(AbstractWidget abstractWidget, int time, AbstractAnimation next) {
        super(abstractWidget, time, next);

        mergin=(float)( (1- min)/0.5);
    }



    @Override
    public void render(GuiGraphics guiGraphics, float partialTicks) {
//        super.render(guiGraphics, partialTicks);
        if (isFinished())
        {
            guiGraphics.pose().pushPose();
            guiGraphics.setColor(1f,1f,1f,rate*mergin);
            abstractWidget.render(guiGraphics,x,y,partialTicks);
            guiGraphics.setColor(1f,1f,1f,1);
            guiGraphics.pose().popPose();
            now=1;
        }
       if(!isFinished())
       {
           if(rate>=0.5)
           {
                guiGraphics.pose().pushPose();
                guiGraphics.setColor(1f,1f,1f,min+rate*mergin-(float) 0.5*mergin);
                abstractWidget.render(guiGraphics,x,y,partialTicks);
               guiGraphics.setColor(1f,1f,1f,1);
                guiGraphics.pose().popPose();
           }
           if(rate<0.5)
           {
               guiGraphics.pose().pushPose();
               guiGraphics.setColor(1f,1f,1f,1-rate*mergin);
               abstractWidget.render(guiGraphics,x,y,partialTicks);
               guiGraphics.setColor(1f,1f,1f,1);
               guiGraphics.pose().popPose();
           }

       }
    }

    @Override
    void customOnFinished(GuiGraphics guiGraphics, float partialTicks) {

    }
}
